<?php

namespace addons\shopro\controller\data;

use addons\shopro\controller\Common;
use app\admin\model\shopro\data\Richtext as RichtextModel;
use app\common\model\shopro\UserReadModel;


class Richtext extends Common
{

    protected $noNeedLogin = ['index'];
    protected $noNeedRight = ['*'];

    public function index()
    {
        $id = $this->request->param('id');

        $data = RichtextModel::where('id', $id)->find();
        if (!$data) {
            $this->error(__('No Results were found'));
        }

        $this->success('获取成功', $data);
    }

    /**
     * @menu 已读
     * ''
     * @Date:2024-04-21 09:55
     */
    public function announcement(){
        $model = new UserReadModel();
        $ids   = 4;
        $info  = $model->where(['user_id'=>$this->auth->id,'richtext_id'=>$ids])->count();
        if(!$info){
            $model->user_id = $this->auth->id;
            $model->richtext_id = $ids;
            $model->save();
            $data = RichtextModel::where('id', $ids)->find();
            $this->success('ok',$data);
        }
        $this->success('已读');
    }
}
